package tests;

import org.junit.Test;
import static org.junit.Assert.*;

import utils.Validator;

/**
 * JUnit Test class for utils.Validator
 * 
 * @author Aleksander Zotov
 * 
 */
public class ValidatorTest {

	@Test
	// Test of isValidDate() with wrong input
	public void isValidDateTest() {
		String invalidDate = "32.01.2013";
		assertTrue(Validator.isValidDate(invalidDate) == false);
	}

	@Test
	// Test of isValidDate() with correct input
	public void isValidDateTest2() {
		String validDate = "23.01.2013";
		assertTrue(Validator.isValidDate(validDate) == true);
	}

	@Test
	// Test of isValidSimName() with correct input
	public void isValidSimNameTest() {
		String validSimName = "Simulation Name 001!";
		assertTrue(Validator.isValidSimName(validSimName) == true);
	}

	@Test
	// Test of isValidSimName() with incorrect input
	public void isValidSimNameTest2() {
		String invalidSimName = "AAAAAAAAAAAAAAAAAAAAAAAA";
		assertTrue(Validator.isValidSimName(invalidSimName) == false);
	}

	@Test
	// Test of isValidSimDescription() with correct input
	public void isValidSimDescriptionTest() {
		String validSimDescription = "";
		assertTrue(Validator.isValidSimDescription(validSimDescription) == true);
	}

	@Test
	// Test of isValidStartEnd() with correct input
	public void isValidStartEndTest() {
		String startDate = "11.01.2013";
		String endDate = "13.01.2013";
		assertTrue(Validator.isValidStartEnd(startDate, endDate) == true);
	}

	@Test
	// Test of isValidStartEnd() with incorrect input
	public void isValidStartEndTest2() {
		String startDate = "11.01.2013";
		String endDate = "09.01.2013";
		assertTrue(Validator.isValidStartEnd(startDate, endDate) == false);
	}

	@Test
	// Test of isValidPassword() with correct input
	public void isValidPasswordTest() {
		String validPassword = "!1ABCDEFGa";
		assertTrue(Validator.isValidPassword(validPassword) == true);
	}

	@Test
	// Test of isValidPassword() with incorrect input
	public void isValidPasswordTest2() {
		String invalidPassword = "Password1";
		assertTrue(Validator.isValidPassword(invalidPassword) == false);
	}

	@Test
	// Test of isValidUsername() with correct input
	public void isValidUsernameTest() {
		String correctUsername = "Username";
		assertTrue(Validator.isValidUsername(correctUsername) == true);
	}

	@Test
	// Test of isValidUsername() with incorrect input
	public void isValidUsernameTest2() {
		String correctUsername = "TooLongUsername";
		assertTrue(Validator.isValidUsername(correctUsername) == false);
	}

	@Test
	// Test of isValidDisctance() with correct input
	public void isValidDistanceTest() {
		String validDistance = "2.5";
		assertTrue(Validator.isValidDistance(validDistance) == true);
	}

	@Test
	// Test of isValidDisctance() with incorrect input
	public void isValidDistanceTest2() {
		String invalidDistance = "-5.0";
		assertTrue(Validator.isValidDistance(invalidDistance) == false);
	}

	@Test
	// Test of isValidTLE() with correct input
	public void isValidTleTest() {
		String validTLE[] = new String[3];
		validTLE[0] = "0 VANGUARD 1";
		validTLE[1] = "1 00005U 58002B   12363.15598079  .00000379  00000-0  48037-3 0   286";
		validTLE[2] = "2 00005 034.2514 350.0193 1846771 319.2698 028.3238 10.84179820909104";
		assertTrue(Validator.isValidTLE(validTLE) == true);
	}

	@Test
	// Test of isValidTLE() with invalid input
	public void isValidTleTest2() {
		String invalidTLE[] = new String[3];
		invalidTLE[0] = "0 VANGUARD 1";
		invalidTLE[1] = "1 00005U 58002B   12363.15598079  .00000379  00000-0  48037-3 0   286";
		invalidTLE[2] = "1 00005 034.2514 350.0193 1846771 319.2698 028.3238 10.84179820909104";
		assertTrue(Validator.isValidTLE(invalidTLE) == false);
	}
}
